﻿#include "findword.h"
#include "ui_findword.h"
#include <QMessageBox>
#include <QDebug>

findWord::findWord(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::findWord)
{
    ui->setupUi(this);

    ui->pushButton_submit->setShortcut(Qt::Key_Return);
    setWindowTitle("客户端");
}



findWord::~findWord()
{
    delete ui;
}

void findWord::on_pushButton_find_clicked()
{

   QString word =  ui->lineEdit->text();
   if(NULL == word)
   {
       QMessageBox::information(this, "警告","单词不能是空的");
       return;
   }
   emit findword(word);
}

void findWord::on_pushButton_history_clicked()
{
   ui->textBrowser->clear();
    emit history();

}

void findWord::show_findword(QString exp)
{
    ui->textBrowser->clear();
    ui->textBrowser->setText(exp);


}

void findWord::show_history(QString history)
{
    ui->textBrowser->clear();
    //  ui->textBrowser->append(history);
    ui->textBrowser->append(history);

}

void findWord::show_reciteWord(QString reciteWord)
{
    ui->textBrowser->clear();
    ui->textBrowser->append(reciteWord);

}

void findWord::on_pushButton_addword_clicked()
{
    QString str = ui->lineEdit->text();
    emit addWord(str);

}

void findWord::on_pushButton_reciteword_clicked()
{
    emit reciteword();
    ui->lineEdit->clear();
}

void findWord::addWord_Message(QString num)
{
    QMessageBox::warning(this,"警告",num);
}

void findWord::deal_CheckWord_Result(QString CheckWordResult)
{
    QMessageBox::warning(this,"警告",CheckWordResult);
}

void findWord::on_pushButton_submit_clicked()
{
    QString str  = ui->lineEdit->text();
    QString str1 = ui->textBrowser->toPlainText();
    emit CheckWord(str,str1);
}
